<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<link rel="stylesheet" type="text/css" href="/Home/Public/CSS/magic-check.css">
<link rel="stylesheet" type="text/css" href="/Home/Public/CSS/test.css">
<script>

    function ok()
    {
        return confirm('确定?');
    }

</script>
<form action = '/index.php/Home/Test/outcome' method = 'POST' >

    <div class = 'fly'><input type="submit" class="btn29" onmouseover="this.style.backgroundPosition='left -43px'" onmouseout="this.style.backgroundPosition='left top'" style="background-position: left top;"  onclick = 'return ok()'>
        <a href = '/index.php/Home/Test/plusKnow'><input type="button" class="btn29" value="添加" onmouseover="this.style.backgroundPosition='left -43px'" onmouseout="this.style.backgroundPosition='left top'" style="background-position: left top;" ></a>
        <?php echo ($retime); ?>
    </div>
    <br><br><br>
    <center>
        <table class = 'imagetable' >
            <tr>
                <th>时间</th>
                <th>功能</th>
                <th>函数</th>
                <th>Try</th>
                <th>TOPIC</th>
                <th>正确率</th>
                <th>SUM</th>
                <th>修改</th>
                <th colspan = '2'>Remember?</th>
            </tr>

            <?php if(is_array($arr_all)): foreach($arr_all as $k=>$v): $classbg = $k%2; ?>
                <tr>
                <td class = td_<?php echo ($classbg); ?>><?php echo ($v["id"]); ?></td>
               <td class = td_<?php echo ($classbg); ?>>
                   <?php if($v["rand"] == 1): ?><details><summary></summary><?php echo ($v["act"]); ?></details>
                       <?php else: ?>
                       <?php echo ($v["act"]); endif; ?>
               </td>
                <td class = td_<?php echo ($classbg); ?>>
                    <?php if($v["rand"] == 2): ?><details><summary></summary><?php echo ($v["fun"]); ?></details>
                    <?php else: ?>
                    <?php echo ($v["fun"]); endif; ?></td>
               <td class = td_<?php echo ($classbg); ?>><input type = 'text'></td>
                <td class = td_<?php echo ($classbg); ?>><?php echo ($v["topic"]); ?></td>
                <td class = td_<?php echo ($classbg); ?>></td>
                <td class = td_<?php echo ($classbg); ?>><?php echo ($v["click"]); ?></td>
                <td class = td_<?php echo ($classbg); ?>><a class = 'del' href='/index.php/Home/Test/delete/id/<?php echo ($v["id"]); ?>' onclick = 'return ok()' >删除</a>
                <a href='/index.php/Home/Test/upd/id/<?php echo ($v["id"]); ?>'>修改</a></td>
                <td class = td_<?php echo ($classbg); ?>><input type = 'radio' id = '<?php echo ($v["id"]); ?>' name ='<?php echo ($v["id"]); ?>' value = 'YES' class='magic-radio'><label for='<?php echo ($v["id"]); ?>'>YES</label></td>
                <td class = td_<?php echo ($classbg); ?>><input type = 'radio'  id = '<?php echo ($v["id"]); ?>1' name = '<?php echo ($v["id"]); ?>'value = 'NO' class='magic-radio'><label for='<?php echo ($v["id"]); ?>1'>NO</label></td>
                </tr><?php endforeach; endif; ?>
        </table>
        <?php echo ($pagelist); ?>
        <hr>
        </form>
        </center>
</body>
<script>

    del = document.getElementsByClassName('del');
    for(var i = 0; i < del.length ; i++) {
        del[i].onclick = function(){
            deleteknow(this);
            return false;
        }
    }
    function deleteknow(ob){
        var xmlhttp = createXMLHttp();
        xmlhttp.onreadystatechange = function(){
            if(xmlhttp.readyState == 4){
                if(xmlhttp.status == 200) {
                    var flag = xmlhttp.responseText;
                    eval("flag="+flag);
                    alert(flag);
                    if(flag != null){
                        for(var i = 0 ;i < del.length; i++){
                            if(flag == del[i].parentNode.parentNode.childNodes[1].innerHTML){
                                var p = del[i].parentNode.parentNode.parentNode;
                                p.removeChild(del[i].parentNode.parentNode);
                                alert('删除成功');
                                break;
                            }
                        }

                        /*   var p = this.parentNode.parentNode.
                         var
                         p.removeChild(this.parentNode.parentNode);*/


                    }else{
                        alert(flag);
                    }

                }
            }
        }

        //            alert(this.parentNode.parentNode.firstChild.nodeValue)
        var dataget = ob.parentNode.parentNode.childNodes[1].innerHTML;

        var url = '/index.php/Home/Test/delete/id/'+dataget;

        xmlhttp.open("GET",url,true);
        xmlhttp.send();
        return false;
        e.preventDefault();

        alert(ob.parentNode.parentNode.childNodes[1].innerHTML);
        return false;
    }




    function createXMLHttp() {
        try{
            return new XMLHttpRequest()
        }catch(e){

        }
        try{
            return new ActiveXObject("Microsoft.XMLHTTP")
        }catch(e){

        }
    }

</script>
</html>